package acwing;

import java.io.*;
import java.util.*;

public class ac798 {
    static final int N = 1010;
    static int[][] a = new int[N][N];
    static int[][] b = new int[N][N];

    public static void main(String[] args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] s1 = in.readLine().split(" ");
        int n = Integer.parseInt(s1[0]);
        int m = Integer.parseInt(s1[1]);
        int q = Integer.parseInt(s1[2]);
        for(int i = 1; i <= n; i ++ ){
            String[] matrix = in.readLine().split(" ");
            for(int j = 1; j <= m; j ++ ){
                a[i][j] = Integer.parseInt(matrix[j - 1]);
            }
        }
        for(int i = 1; i <= n; i ++ ){
            for(int j = 1; j <= m; j ++ ){
                Insert(i, j, i, j, a[i][j]);
            }
        }
        while (q -- > 0) {
            String[] sw = in.readLine().split(" ");
            int x1 = Integer.parseInt(sw[0]);
            int y1 = Integer.parseInt(sw[1]);
            int x2 = Integer.parseInt(sw[2]);
            int y2 = Integer.parseInt(sw[3]);
            int c = Integer.parseInt(sw[4]);
            Insert(x1, y1, x2, y2, c);
        }
        for(int i = 1; i <= n; i ++ ){
            for(int j = 1; j <= m; j ++ ){
                b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
            }
        }
        for(int i = 1; i <= n; i ++ ){
            for(int j = 1; j <= m; j ++ ){
                System.out.print(b[i][j] + " ");
            }
            System.out.println();
        }
    }

    public static void Insert(int x1, int y1, int x2, int y2, int c){
        b[x1][y1] += c;
        b[x1][y2 + 1] -= c;
        b[x2 + 1][y1] -= c;
        b[x2 + 1][y2 + 1] += c;

    }
}

class Input {
    StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    public int nextInt() throws IOException {
        in.nextToken();
        return (int)in.nval;
    }
}
